<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<p align="center">还有<font color="red" id="time">5</font>秒自动跳转!</p>

		<script>
			var i = 5;
			// 获取事件
			var time = document.getElementById("time");
			//延时五秒
			setInterval(fun, 1000);

			function fun() {
				//获取文本
				time.innerHTML = String(i--);
				//跳转页面
				if (i <= 0) {
					location.href = 'https://www.baidu.com';
					clearInterval();
				}
			}
		</script>
	</body>
</html>
